<?php
$this->rmenu = array(
	array('label'=>'New packing list template','url'=>array('/packing_list_details/create')),
);
$this->menu = array(
	array('label'=>'List packing list', 'url'=>array('list')),
	array('label'=>'Manage packing list', 'url'=>array('admin')),
);
?>

<h1>Choosing Template</h1>

<?php $this->widget('zii.widgets.CListView', array(
	'dataProvider'=>$dataProvider,
	'itemView'=>'_listDetail',
)); ?>
<?php 
$cs = Yii::app()->getClientScript();
$viewURL = CHtml::normalizeUrl(array('packing_list/view'));
$script =<<<EOD
$('#createPacking').live('click',function(){
	var dialogButton = {
		Add:function(){
			var constructor = $(this);
			$.packing_list_form={
				afterSubmit:function(data){
					$(constructor).dialog('close');
					if(data.id != '')
						window.location = "$viewURL?id="+data.id; 
				}
			};
			$(this).find('form').find('[type=submit]').click();
		}
	};
	$.simplelogdialog({url:$(this).attr('href')},{width:350},dialogButton);
	return false;
});
EOD;
$cs->registerScript('packing_list_detail_view',$script);
?>